<?php
session_start();
require_once '../header.php';
function __autoload($className)
	{
    	require_once('../class/' . $className . '.class.php');
	}
session::need_member();
$UserId=session::getuserid();
$post=$_POST;
$lr_paidto=rtrim(trim($_post["lr_paidto"]));
$lr_paidby=rtrim(trim($post["lr_paidby"]));
$lr_store="freshstoreactive";
$lr_amnt=rtrim(trim($post["lr_amnt"]));
$lr_transfer=rtrim(trim($post["lr_transfer"]));
$lr_currency=rtrim(trim($post["lr_currency"]));
$secret_word="vca@#%#3252VDs";
$hashPost=rtrim(trim($post["lr_encrypted"]));
$hashword="U6593813:$lr_paidby:$lr_store:$lr_amnt:$lr_transfer:$lr_currency:$secret_word";
$hash=hash("SHA256", $hashword);
$Uper=strtoupper($hash);
if($Uper==$hashPost)
{
	$checkBatch=user::checkpermission("lrverifier","verifier=$lr_transfer", "lrid is not null");
	if($checkBatch=='0')
	{
		
		$lrAmount=intval($lr_amnt);
		$balancePlus=abs($lrAmount);
		$batch=intval($lr_transfer);
		$insertBatch=database::Insert("lrverifier", array(
		'verifier' => $batch
		));
	 	$Date=date("Y-m-d");
		if($balancePlus>=40)
		{
			$balanceUser=ceil($balancePlus-20);
			database::Insert('payment', array('userid' => $UserId,'date' => $Date,'amount' => $balancePlus,'reason' => "Active Account: $lr_paidby : $batch ",'lr' => $balancePlus));
			database::Update('userinfo',array('userid' => $UserId),array('money' => array( "money + {$balanceUser}"),'isactive'=>'1','deposit' => array("deposit + {$balanceUser}")));
			$_SESSION["erro"]="Successful ! Your Account has been Actived and now your balance is $balanceUser";
			redirect::location("../membercp.php");
		}
		else if(($lrAmount>0)&&($lrAmount<40))
		{
			
			database::Insert('payment', array('userid' => $UserId,'date' => $Date,'amount' => $AmountAfterPlus,'reason' => "Can not Active Account: $lr_paidby : $batch ",'lr' => $balancePlus));
			redirect::location("../login.php");
		}
		else
		{
			redirect::location("../login.php");
		}
		
		
	}
	else
	{
	
		$_SESSION["erro"]="Problem with your payment, make sure you have made the payment,plz create new ticket and our staff will solve this problem";
		redirect::location("../login.php");
		
	}
}
else 
{
	$_SESSION["erro"]="Problem with your payment, make sure you have made the payment";
	redirect::location("../login.php");
}

?>